package com.study.mybatis.proxy;

import com.study.mybatis.config.Confingurtion;
import com.study.mybatis.session.SqlSession;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MapperProxy implements InvocationHandler {

    private SqlSession sqlSession;
    public MapperProxy(SqlSession sqlSession){
        this.sqlSession = sqlSession;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        String statementId = method.getDeclaringClass().getName()+"."+method.getName();
        return sqlSession.selectOne(statementId,args[0]);
    }
}
